#ifndef CANOPEN_SDO_H
#define CANOPEN_SDO_H

#include <QObject>

enum
{
    CANOPEN_OD_RO = 0 ,
    CANOPEN_OD_WO = 2 ,
    CANOPEN_OD_RW = 4,
};
enum
{
    CANOPEN_OD_LENGTH_BYTE = 1,
    CANOPEN_OD_LENGTH_HALFWORD = 2,
    CANOPEN_OD_LENGTH_WORD = 4,
};
enum
{
    CANOPEN_SDO_W1 = 0x2F,
    CANOPEN_SDO_W2 = 0x2B,
    CANOPEN_SDO_W4 = 0x23,
    CANOPEN_SDO_RD = 0x40,
};
enum
{
    CANOPEN_SDO_R1 = 0x4F,
    CANOPEN_SDO_R2 = 0x4B,
    CANOPEN_SDO_R4 = 0x43,
    CANOPEN_SDO_RESP = 0x60,
};

class odTable
{
public:
    uint32_t id ;
    uint16_t index;    // 对象索引
    uint8_t sub_index; // 子索引
    uint8_t rw;        // 读写权限
    uint8_t length;    // 数据长度
    void * data ;
};

class OdParam
{
public:
    uint32_t soft_version_pmu;
    uint32_t soft_version_bdu;
    uint32_t soft_version_wdu;
    uint32_t soft_version_hou;
    uint32_t param_first_save_flag;
    uint32_t water_suck_down_time_default;
    uint32_t water_suck_delay_up_time_default;
    uint32_t brush_push_down_time_default;
    uint32_t brush_push_down_time_max;
    uint32_t suction_delay_off_time_default;

    uint32_t spray_water_duty_gear1;
    uint32_t spray_water_duty_gear2;
    uint32_t spray_water_duty_gear3;
    uint32_t left_right_brush_duty_default;
    uint32_t suction_duty_default;
    uint32_t brush_power_gear1;
    uint32_t brush_power_gear2;
    uint32_t brush_power_gear3;
    uint32_t function_switch_mask;
    uint32_t pump_type;
    uint32_t brush_push_overload;
    uint32_t clean_water_empty_disable;
    uint32_t dirty_water_empty_disable;
};

class CanOpenSdo
{
public:
    CanOpenSdo();
    OdParam odParam;
    std::vector<odTable> od_table_list ;
    bool canOpenSdoHandle(uint32_t id ,uint8_t *data);
    odTable *getOdTableByIndex(uint32_t id ,uint32_t index ,uint8_t sub_index);
    void printParam(void);

signals:

};

#endif // CANOPEN_SDO_H
